<template>
    <div>
        <van-nav-bar title="订单页面" left-text="返回" left-arrow @click-left="() => { $router.push('/') }" fixed />
        <div style="height: 45px;"></div>
        <van-address-list v-model="chosenAddressId" :list="list" :disabled-list="disabledList" default-tag-text="默认"
            @add="onAdd" @edit="onEdit" add-button-text="去下单" @click="btn"/>
        <van-cell-group>
            <van-cell title="订单时间" :value="data.create_time" />
            <van-cell title="订单号" :value="data.orderId" />
            <van-cell title="商品名称" :value="data.product_code" />
            <van-cell title="订单价格" :value="data.totalPrice" />
            <van-cell title="用户信息" :value="data.username" />
        </van-cell-group>
    </div>
</template>

<script setup>
const list = [
    {
        id: '1',
        name: '张三',
        tel: '13000000000',
        address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        isDefault: true,
    },
]
import { useRoute } from 'vue-router';
const route = useRoute()
console.log(route.params.orderId);

import { getOrderApi } from '@/api/api'
import {payApi} from '@/api/api'
import { ref } from 'vue';
let data = ref([])
let fendata=ref([])
getOrderApi(route.params.orderId).then(res => {
    console.log(res);
    data.value=res.data.data
    fendata.value={
        orderId:res.data.data.orderId,
        subject:res.data.data.product_code,
        totalPrice:res.data.data.totalPrice
    }
})
const btn=()=>{
    payApi(fendata.value).then(res=>{
        console.log(res);
        window.open(res.data.data,'_blank')
    })
}
</script>

<style lang="scss" scoped></style>